package com.cysion.study.adapter

import android.content.Context
import android.text.TextUtils
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.bumptech.glide.Glide
import com.bumptech.glide.request.RequestOptions
import com.cysion.study.ktbox.base.BaseAdapter
import com.cysion.study.ktbox.base.BaseViewHolder
import com.cysion.study.R
import com.cysion.study.entity.CommentListEntity
import kotlinx.android.synthetic.main.item_carousel_square.view.*
import kotlinx.android.synthetic.main.item_history_comment.view.*

class HistoryCommentAdapter(mEntities: MutableList<CommentListEntity>, mContext: Context) :
    BaseAdapter<CommentListEntity>(mEntities, mContext) {

    companion object {

        //点击事件
        const val preview = 101
        const val refuse = 102
        const val del = 103
        const val modify = 104
    }

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BaseViewHolder<CommentListEntity> {
        return ProMoneyHolder(
            LayoutInflater.from(mContext).inflate(R.layout.item_history_comment, parent, false)
        )
    }

    class ProMoneyHolder(itemView: View) : BaseViewHolder<CommentListEntity>(itemView) {
        override fun fillData(obj: CommentListEntity, position: Int) {
            itemView?.apply {
                if (!TextUtils.isEmpty(obj.content)) {
                    tv_content.text=obj.content
                }
                if (!TextUtils.isEmpty(obj.imageurl)) {
                    Glide.with(mContext).load(obj.imageurl).apply(
                        RequestOptions().placeholder(R.mipmap.place_holder_big)
                    ).into(iv_img)
                }
                /*itemView.tv_del._setOnClickListener {
                    mOnTypeClickListener?.invoke(obj, position, del)
                } */

            }
        }

    }
}